package org.lzfto.flink.demo.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.NestedConfigurationProperty;
import org.springframework.stereotype.Component;

@Component
@ConfigurationProperties(prefix = "myapp")
public class MyAppProperties {
    private String name;
    private String tableConfig;
    private Boolean mqttEnabled;
    private String  mqttTopicPrefix;
    private String  mqttConsumerClientName;
    private String  mqttProducerClientName;
    private Integer mqttQos;
    private Boolean mqttAutoReconnect;
    private Integer webSocketTimeout;
    private String flinkAddress;
    private String  uploadDirectory;

    @NestedConfigurationProperty
    private DataSourceProperties datasource;

    // Getters and Setters


    public String getUploadDirectory() {
        return uploadDirectory;
    }

    public void setUploadDirectory(String uploadDirectory) {
        this.uploadDirectory = uploadDirectory;
    }

    public String getName() {
        return name;
    }

    public String getFlinkAddress() {
		return flinkAddress;
	}

	public void setFlinkAddress(String flinkAddress) {
		this.flinkAddress = flinkAddress;
	}

	public Boolean getMqttAutoReconnect() {
		return mqttAutoReconnect;
	}

	public void setMqttAutoReconnect(Boolean mqttAutoReconnect) {
		this.mqttAutoReconnect = mqttAutoReconnect;
	}

	public Integer getMqttQos() {
		return mqttQos;
	}

	public void setMqttQos(Integer mqttQos) {
		this.mqttQos = mqttQos;
	}

	public Integer getWebSocketTimeout() {
		return webSocketTimeout;
	}

	public void setWebSocketTimeout(Integer webSocketTimeout) {
		this.webSocketTimeout = webSocketTimeout;
	}

	public Boolean getMqttEnabled() {
        return mqttEnabled;
    }

    public void setMqttEnabled(Boolean mqttEnabled) {
        this.mqttEnabled = mqttEnabled;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getTableConfig() {
        return tableConfig;
    }

    public void setTableConfig(String tableConfig) {
        this.tableConfig = tableConfig;
    }

    public DataSourceProperties getDatasource() {
        return datasource;
    }

    public void setDatasource(DataSourceProperties datasource) {
        this.datasource = datasource;
    }

    public static class DataSourceProperties {
        private String url;
        /**
         * 实际不用
         */
        private String username;
        /**
         * 实际不用
         */
        private String password;
        private String driverClassName;
        private HikariProperties hikari;

        // Getters and Setters
        public String getUrl() {
            return url;
        }

        public void setUrl(String url) {
            this.url = url;
        }

        public String getUsername() {
            return username;
        }

        public void setUsername(String username) {
            this.username = username;
        }

        public String getPassword() {
            return password;
        }

        public void setPassword(String password) {
            this.password = password;
        }

        public String getDriverClassName() {
            return driverClassName;
        }

        public void setDriverClassName(String driverClassName) {
            this.driverClassName = driverClassName;
        }

        public HikariProperties getHikari() {
            return hikari;
        }

        public void setHikari(HikariProperties hikari) {
            this.hikari = hikari;
        }
    }

    public static class HikariProperties {
        private String poolName;
        private boolean autoCommit;
        private long connectionTimeout;
        private long idleTimeout;
        private long maxLifetime;
        private int maximumPoolSize;
        private int minimumIdle;
        private String connectionTestQuery;

        // Getters and Setters
        public String getPoolName() {
            return poolName;
        }

        public void setPoolName(String poolName) {
            this.poolName = poolName;
        }

        public boolean isAutoCommit() {
            return autoCommit;
        }

        public void setAutoCommit(boolean autoCommit) {
            this.autoCommit = autoCommit;
        }

        public long getConnectionTimeout() {
            return connectionTimeout;
        }

        public void setConnectionTimeout(long connectionTimeout) {
            this.connectionTimeout = connectionTimeout;
        }

        public long getIdleTimeout() {
            return idleTimeout;
        }

        public void setIdleTimeout(long idleTimeout) {
            this.idleTimeout = idleTimeout;
        }

        public long getMaxLifetime() {
            return maxLifetime;
        }

        public void setMaxLifetime(long maxLifetime) {
            this.maxLifetime = maxLifetime;
        }

        public int getMaximumPoolSize() {
            return maximumPoolSize;
        }

        public void setMaximumPoolSize(int maximumPoolSize) {
            this.maximumPoolSize = maximumPoolSize;
        }

        public int getMinimumIdle() {
            return minimumIdle;
        }

        public void setMinimumIdle(int minimumIdle) {
            this.minimumIdle = minimumIdle;
        }

        public String getConnectionTestQuery() {
            return connectionTestQuery;
        }

        public void setConnectionTestQuery(String connectionTestQuery) {
            this.connectionTestQuery = connectionTestQuery;
        }
    }

    /**
     * @return Boolean return the mqttEnabled
     */
    public Boolean isMqttEnabled() {
        return mqttEnabled;
    }

    /**
     * @return String return the mqttTopic
     */
    public String getMqttTopicPrefix() {
        return mqttTopicPrefix;
    }

    /**
     * @param mqttTopicPrefix the mqttTopic to set
     */
    public void setMqttTopicPrefix(String mqttTopicPrefix) {
        this.mqttTopicPrefix = mqttTopicPrefix;
    }


    /**
     * @return String return the mqttConsumerClientName
     */
    public String getMqttConsumerClientName() {
        return mqttConsumerClientName;
    }

    /**
     * @param mqttConsumerClientName the mqttConsumerClientName to set
     */
    public void setMqttConsumerClientName(String mqttConsumerClientName) {
        this.mqttConsumerClientName = mqttConsumerClientName;
    }

    /**
     * @return String return the mqttProducerClientName
     */
    public String getMqttProducerClientName() {
        return mqttProducerClientName;
    }

    /**
     * @param mqttProducerClientName the mqttProducerClientName to set
     */
    public void setMqttProducerClientName(String mqttProducerClientName) {
        this.mqttProducerClientName = mqttProducerClientName;
    }

}
